package ch.zbw.sysventory.server.service.security.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import ch.zbw.sysventory.server.model.UserRole;
import ch.zbw.sysventory.server.repository.UserRoleRepository;
import ch.zbw.sysventory.server.service.security.UserRoleService;

@Transactional
@Service
public class UserRoleServiceImpl implements UserRoleService {

	@Autowired(required = true)
	private UserRoleRepository userRoleRepository;

	@Override
	public UserRole get(Long id) {
		return this.userRoleRepository.findOne(id);
	}

	@Override
	public List<UserRole> list() {
		return this.userRoleRepository.findAll();
	}

	@Override
	public UserRole getByName(String name) {
		List<UserRole> roles = this.userRoleRepository.findByName(name);
		return roles.get(0);
	}

}
